/*
 * @Date: 2025-11-07 18:06:16
 * @Auth: 873768511@qq.com
 * @LastEditors: 873768511@qq.com
 * @LastEditTime: 2025-11-11 14:31:55
 * @FilePath: \corpus\src\services\systemManagement\role\index.ts
 */

import type { IPageResult, IResult } from '@/types/global';
import { request } from '@umijs/max';

import type {
  IRoleCreateRequest,
  IRoleDeatil,
  IRoleList,
  IRolePageRequest,
} from '@/types/systemManagement/role';

/**
 * 获取角色列表
 */
export async function postRoleList(data: IRolePageRequest) {
  return request<IPageResult<IRoleList>>(`/corpus/knowledgeRole/getRoleList`, {
    method: 'POST',
    data
  });
}

/**
 *  删除角色
 */
export async function deleteRoleInfo(params: { id: number }) {
  return request<IResult<boolean>>(`/corpus/knowledgeRole/deleteRole`, {
    method: 'GET',
    params
  });
}

/**
 *  新增角色
 */
export async function postRoleCreate(data: IRoleCreateRequest) {
  return request<IResult<boolean>>(`/corpus/knowledgeRole/addRole`, {
    method: 'POST',
    data
  });
}

/**
 *  编辑角色
 */
export async function postRoleUpdate(data: IRoleCreateRequest) {
  return request<IResult<boolean>>(`/corpus/knowledgeRole/updateRole`, {
    method: 'POST',
    data
  });
}

// 设置角色状态
export async function setRoleStatus(data: { id: number; status: number }) {
  return request<IResult<boolean>>(`/corpus/knowledgeRole/updateRole`, {
    method: 'POST',
    data
  });
}


/**
 *  获取单个角色详情
 */
export async function postRoleInfo(params: { id: number }) {
  return request<IResult<IRoleDeatil>>(`/corpus/knowledgeRole/getRole`, {
    method: 'GET',
    params
  })
}